﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 武学面板
/// </summary>
public class WuxuePanel : ShowHideBehaviour {

    private WuxueListPanel WuxueListPanel;
    private WuxueInfoPanel WuxueInfoPanel;

	// Use this for initialization
	void Start () {
        base.InitShowHide();
        Transform wuxueBoxTransform = this.transform.Find("WuxueBox");
        this.WuxueListPanel = wuxueBoxTransform.Find("WuxueListPanel").GetComponent<WuxueListPanel>();
        this.WuxueInfoPanel = wuxueBoxTransform.Find("WuxueInfoPanel").GetComponent<WuxueInfoPanel>();
    }
	
	// Update is called once per frame
	void Update () {
        base.HandleShowHide();
	}

    public void ClickAllButton() {
        Personage player = GlobalData.Instance.GetPlayerPersonage();
        List<PersonageWuxue> wuxues = player.OwnWuxues;
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickFistButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.WuxueCategory.Fist);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickLegButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.WuxueCategory.Leg);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickSwordButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.WuxueCategory.Sword);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickKnifeButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.WuxueCategory.Knife);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickStickButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.WuxueCategory.Stick);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickSpeedButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.WuxueCategory.Speed);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickInternalWorkButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.WuxueCategory.InternalWork);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickAttackButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.ActionCategory.Attack);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }

    public void ClickDefenseButton() {
        List<PersonageWuxue> wuxues = this.GetPersonageWuxues(Constant.ActionCategory.Defense);
        this.WuxueListPanel.Refresh(wuxues);
        this.WuxueInfoPanel.Refresh(wuxues);
    }
    
    private List<PersonageWuxue> GetPersonageWuxues(Constant.WuxueCategory wuxueCategory) {
        Personage player = GlobalData.Instance.GetPlayerPersonage();
        return player.GetWuxuesByCategory(wuxueCategory);
    }

    private List<PersonageWuxue> GetPersonageWuxues(Constant.ActionCategory actionCategory) {
        Personage player = GlobalData.Instance.GetPlayerPersonage();
        return player.GetWuxuesByCategory(actionCategory);
    }
}
